/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.cezary.butler.walili.server.db.utils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import pl.cezary.butler.walili.server.db.Database;
/**
 *
 * @author Cezary Butler
 */
public class StorageBD {
    
    private static final Map<String,Database> registry = new ConcurrentHashMap<String, Database>();
    private static Database bd;
    
    static{
        
    }
    
    public void setBd(Database abd){
        bd=abd;
        registerBD("main", abd);
    }
    
    public void setClientDb(Database cbd){
        registerBD("client", bd);
    }
    
    public static void registerBD(String nazwa,Database baza){
        registry.put(nazwa, baza);
    }
    
    public static void unregisterBD(String nazwa){
        registry.remove(nazwa);
    }
    
    public static Database getBD(String nazwa){
        return registry.get(nazwa);
    }
    
    public static Database getBD(){
        return bd;
    }
    
    public static Database getClientDb(){
        return registry.get("client");
    }
}
